
package com.lzb.compressmaster.adapter;

import android.graphics.Color;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.lzb.compressmaster.R;
import com.lzb.compressmaster.basic.ProviderMultiAdapter;
import com.lzb.compressmaster.bean.ResolutionBean;

public class ResolutionAdapter extends ProviderMultiAdapter<ResolutionBean> {

    public ResolutionAdapter() {
        addItemProvider(new ResolutionProvider());
    }

    private class ResolutionProvider extends BaseItemProvider<ResolutionBean> {
        @Override
        public int getItemViewType() {
            return ProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_resolution;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, ResolutionBean bean) {
            baseViewHolder.setText(R.id.tvResolutionItemName, bean.getName());
            if (bean.isSelected()) {
                baseViewHolder.setBackgroundResource(R.id.tvResolutionItemName, R.drawable.compress_mode_sel);
                baseViewHolder.setTextColor(R.id.tvResolutionItemName, Color.parseColor("#FFFFFF"));
            } else {
                baseViewHolder.setBackgroundResource(R.id.tvResolutionItemName, R.drawable.compress_mode_bg);
                baseViewHolder.setTextColor(R.id.tvResolutionItemName, Color.parseColor("#333333"));
            }
        }
    }

}
